/**
 * 746. 使用最小花费爬楼梯
 */
public class MinCostClimbingStairs {
    public int minCostClimbingStairs(int[] cost) {
        int len = cost.length;
        int[] dp = new int[len + 1]; // 表示到第i个台阶的花费
        dp[0] = dp[1] = 0;
        for (int i = 2; i <= len; i++) {
            dp[2] = Math.min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
        }
        return dp[len];
    }
}
